package zhaomh.zhlib.config;

import zhaomh.zhlib.util.TextUtil;

import java.util.ArrayList;
import java.util.List;

public class EnumValue extends Value {
    private final List<String> values;
    private String value;
    public EnumValue(String name, List<String> values) {
        super(name);
        this.values = values;
        this.value = values.getFirst();
    }

    public void next(){
        int newIndex = values.indexOf(value)+1;
        if (newIndex >= values.size()) {
            newIndex = 0;
        }
        value = values.get(newIndex);
        notifyListeners();
    }

    public String getTr() {
        return TextUtil.Translatable(get()).getString();
    }

    public String get() {
        return value;
    }

    public void set(String value) {
        this.value = value;
        notifyListeners();
    }

    public List<String> getAll() {
        return new ArrayList<>(values);
    }
}
